﻿<sap:ActivityDesigner x:Class="Common.Activities.Design.ClearViewsFromRegionDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
                      xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
                      xmlns:s="clr-namespace:System;assembly=mscorlib">

    <sap:ActivityDesigner.Resources>
        <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
        <sapc:ModelToObjectValueConverter x:Key="ModelToObjectValueConverter"/>

        <DataTemplate x:Key="Collapsed">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding ModelItem.ViewName, Converter={StaticResource ArgumentToExpressionConverter}, FallbackValue=Invalid}"/>
                <TextBlock Text=" -> "/>
                <TextBlock Text="{Binding ModelItem.RegionName, Converter={StaticResource ArgumentToExpressionConverter}, FallbackValue=Invalid}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="Expanded">
            <Grid>
                <Grid.Resources>
                    <Style x:Name="TextBlock" TargetType="TextBlock">
                        <Setter Property="VerticalAlignment" Value="Center"/>
                    </Style>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>


                <TextBlock Grid.Row="0" Grid.Column="0" Text="Region Name:"/>
                <Border Grid.Row="0" Grid.Column="1" BorderBrush="Black" BorderThickness="0.5" Margin="3,0,3,0">
                    <sapv:ExpressionTextBox x:Name="RegionNameValue"  Expression="{Binding ModelItem.RegionName, Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In}" HintText="Enter name of UI Region" ExpressionType="s:String" OwnerActivity="{Binding ModelItem}" />
                </Border>

            </Grid>
        </DataTemplate>
        <Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="False">
                    <Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </sap:ActivityDesigner.Resources>

    <Grid>
        <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />
    </Grid>
</sap:ActivityDesigner>
